<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


    <link type="text/css" rel="stylesheet" href="../css/font_2351238_ytdcrvdnz3b.css">
    <!-- <link rel="stylesheet" href="../css/materialdesignicons.min.css"> -->


    <link rel="stylesheet" href="../css/chunk-vendors.c41b385c.css">

    <link rel="stylesheet" href="../css/chunk-common.cce6e03e.css">

    <link rel="stylesheet" href="../css/page.481d5dac.css">


    <!---->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>图书电商-注册</title>
    <!-- <link rel="stylesheet" type="text/css" href="../css/chunk-383eb23e.44dfe883.css"> -->
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script>
        window.onload = function () {
            // $(function() {}) 是$(document).ready(function()的简写,DOM 加载完毕之后执行。
            // $(function () {
            $(document).ready(function () {
                $("#submit").on("click", function () {
                    const username = $("input[name='username']").val();
                    const password = $("input[name='password']").val();
                    const relPwd = $("input[name='relPwd']").val();
                    if (username == "" || password == "" || relPwd == "") {
                        alert("所有信息不可为空，请确认！");
                        return;
                    } else if (password != relPwd) {
                        alert("两次密码输入不一致！");
                        return;
                    }

                    $.post("../server/register.php", {
                        "username": username,
                        "password": password,
                    }, function (data) {
                        alert(data);

                        if (data == "注册成功") {
                            location = "./login.html";
                        }
                    })

                });
            });
        }
    </script>
</head>

<body class="auth-register tw-text-base">

    <div class="hero  is-fullheight">
        <div class="hero-body tw-relative">
            <div class="container tw-flex-grow-0">
                <div class="columns is-centered">
                    <div class="column is-4" style="width: 500px;">
                        <div class="box tw-p-8">
                            <h1 class="has-text-centered tw-text-333333" style="font-size: 22.99px;">
                                欢迎注册</h1><br>
                            <form action="../server/register.php" method="POST">
                                <div class="field a">
                                    <!---->
                                    <div class="control"><input type="text" autocomplete="off" name="username"
                                            placeholder="设置用户名" class="input">
                                        <!---->
                                        <!---->
                                        <!---->
                                    </div>
                                    <p class="help"></p>
                                </div>
                                <div class="field a">
                                    <!---->
                                    <div class="control"><input type="password" autocomplete="new-password"
                                            name="password" placeholder="设置密码" class="input">
                                        <!---->
                                        <!---->
                                        <!---->
                                    </div>
                                    <p class="help"></p>
                                </div>
                                <div class="field a">
                                    <div class="control"><input type="password" autocomplete="on" placeholder="确认密码"
                                            name="relPwd" class="input">

                                    </div>
                                    <p class="help"></p>
                                </div>
                                <div class="field">
                                    <!----><button class="button is-primary is-fullwidth" id="submit">
                                        <!----><span>创建账号
                                        </span>
                                        <!----></button>
                                    <!---->
                                </div>
                                <div class="level tw-text-xs">
                                    <div class="level-left"></div>
                                    <div class="level-right">
                                        <div class="level-item">
                                            已有账号? <a href="./login.html">立即登陆</a></div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


</body>

</html>